package cn.dankal.basiclib.api;

import java.util.List;
import java.util.Map;

import cn.dankal.annotations.ApiFactory;
import cn.dankal.basiclib.pojo.AddressEntity;
import cn.dankal.basiclib.pojo.ApplyAfterSalesEntity;
import cn.dankal.basiclib.pojo.BaseListResponse;
import cn.dankal.basiclib.pojo.BaseResponse;
import cn.dankal.basiclib.pojo.CardDetailEntity;
import cn.dankal.basiclib.pojo.CommentsEntity;
import cn.dankal.basiclib.pojo.CreateOrderPreviewEntity;
import cn.dankal.basiclib.pojo.FavoritesShopEntity;
import cn.dankal.basiclib.pojo.InputLogiReq;
import cn.dankal.basiclib.pojo.LogisticsEntity;
import cn.dankal.basiclib.pojo.MyCommentReq;
import cn.dankal.basiclib.pojo.ProductEntity;
import cn.dankal.basiclib.pojo.ShopCarEntity;
import cn.dankal.basiclib.pojo.SignInEntity;
import cn.dankal.basiclib.pojo.StoreHomeEntity;
import cn.dankal.basiclib.pojo.UserScoresEntity;
import cn.dankal.basiclib.pojo.UserScoresLogsEntity;
import cn.dankal.basiclib.pojo.WexinPayResult;
import cn.dankal.basiclib.pojo.req.AddShopCarReq;
import cn.dankal.basiclib.pojo.req.CreateOrderReq;
import cn.dankal.basiclib.pojo.req.FavoritesShopReq;
import cn.dankal.basiclib.pojo.req.SubCommentsReq;
import cn.dankal.business.pojo.CommentBean;
import io.reactivex.Observable;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.PATCH;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.http.QueryMap;

/**
 * Date: 2018/7/27.
 * Time: 17:44
 * classDescription:
 * 个人中心
 *
 * @author fred
 */

@ApiFactory(value = BaseApiByShop.class)
public interface ShopUserService {

    /**
     * 修改地址
     */
    @POST("frontapi/user-addresses")
    Observable<BaseResponse<AddressEntity>> addUserAddress(@Body AddressEntity params);

    /**
     * 获取地址
     */
    @GET("frontapi/user-addresses")
    Observable<BaseResponse<List<AddressEntity>>> getUserAddress();

    /**
     * 修改地址
     */
    @PUT("frontapi/user-addresses")
    Observable<BaseResponse<AddressEntity>> putUserAddress(@Body AddressEntity params);

    /**
     * 删除地址
     */
    @DELETE("frontapi/user-addresses/{uuid}")
    Observable<BaseResponse<Object>> deleteAddress(@Path("uuid") String uuid);

    @POST("frontapi/sign-in")
    Observable<BaseResponse<Object>> doSignIn();

    @GET("frontapi/if-sign-in")
    Observable<BaseResponse<Boolean>> isSginIn();


    @GET("frontapi/get-sign-in")
    Observable<BaseResponse<SignInEntity>> getSignIn();

    @GET("frontapi/products")
    Observable<BaseResponse<BaseListResponse<ProductEntity>>> searchShop(@QueryMap Map<String, Object> params);

    @GET("frontapi/products/{uuid}")
    Observable<BaseResponse<ProductEntity>> shopDetail(@Path("uuid") String uuid);

    /**
     * 获取用户积分
     *
     * @return
     */
    @GET("frontapi/user-scores")
    Observable<BaseResponse<UserScoresEntity>> userScores();

    /**
     * 获取用户积分明细
     *
     * @return
     */
    @GET("frontapi/user-score-logs")
    Observable<BaseResponse<BaseListResponse<UserScoresLogsEntity>>> userScoresLogs(@Query("page") int page, @Query("size") int size);


    /**
     * 收藏商品
     *
     * @param req
     * @return
     */
    @POST("frontapi/user-favorites")
    Observable<BaseResponse<Object>> favoritesShop(@Body FavoritesShopReq req);

    /**
     * 我的收藏
     *
     * @param
     * @return
     */
    @GET("frontapi/user-favorites")
    Observable<BaseResponse<BaseListResponse<FavoritesShopEntity>>> myFavoritesShop();

    /**
     * 取消收藏 支持数据 ，分割
     *
     * @param uuid
     * @return
     */
    @DELETE("frontapi/user-favorites/{uuid}")
    Observable<BaseResponse<Object>> cancelFavoritesShop(@Path("uuid") String uuid);


    /**
     * 加入购物车
     *
     * @param req
     * @return
     */
    @POST("frontapi/carts")
    Observable<BaseResponse<Object>> addShopCar(@Body AddShopCarReq req);

    @POST("frontapi/carts/productCount")
    Observable<BaseResponse<Object>> productCount(@Body AddShopCarReq req);
    /**
     * 加入购物车
     *
     * @return
     */
    @DELETE("frontapi/carts/{uuid}")
    Observable<BaseResponse<Object>> deleteShopCar(@Path("uuid") String uuid);


    /**
     * 我的购物车
     * * @return
     */
    @GET("frontapi/carts")
    Observable<BaseResponse<List<ShopCarEntity>>> mySHopCar();
//0777f9c48fa74a14ba6be8d0cb0f7ac8

    /**
     * 商城首页接口
     *
     * @return
     */
    @GET("frontapi/home")
    Observable<BaseResponse<StoreHomeEntity>> storeHome();

    /**
     * 下单
     *
     * @return
     */
    @POST("frontapi/orders")
    Observable<BaseResponse<String>> createOrder(@Body CreateOrderReq req);


    @GET("frontapi/order-product-comments")
    Observable<BaseResponse<BaseListResponse<CommentsEntity>>> comments(@QueryMap Map<String,
            Object> params);

    /**
     * 生成订单预览
     *
     * @return
     */
    @POST("frontapi/orders/preview")
    Observable<BaseResponse<CreateOrderPreviewEntity>> createOrderPreview(@Body CreateOrderReq req);

    @POST("frontapi/payment/wx")
    @FormUrlEncoded
    Observable<BaseResponse<WexinPayResult>> wx(@Field("orderUuid") String orderUuid);

    @POST("frontapi/payment/alipay")
    @FormUrlEncoded
    Observable<BaseResponse<String>> alipay(@Field("orderUuid") String orderUuid);

    /**
     * 下单
     *
     * @return
     */
    @GET("frontapi/orders")
    Observable<BaseResponse<BaseListResponse<CreateOrderPreviewEntity>>> getOrders(@Query("page") int page, @Query("size") int size,
                                                                                   @Query("orderState") String orderState);

    /**
     * 下单
     *
     * @return
     */
    @GET(" frontapi/orders/{uuid}")
    Observable<BaseResponse<CreateOrderPreviewEntity>> getOrderDetails(@Path("uuid") String uuid);


    /**
     * 下单
     *
     * @return
     */
    @DELETE("frontapi/orders/{orderUuid}")
    Observable<BaseResponse<Object>> cancelOrder(@Path("orderUuid") String uuid, @Query("reason") String reason);

    /**
     * 生成订单预览
     *
     * @return
     */
    @POST("frontapi/orders/{uuid}/receive")
    Observable<BaseResponse<Object>> confirmReceive(@Path("uuid") String uuid);

    @POST("frontapi/order-product-comments")
    Observable<BaseResponse<Object>> comments(@Body MyCommentReq myCommentReq);

    /**
     * 订单物流详情
     *
     * @param orderUuid 订单id
     * @return
     */
    @GET("frontapi/orders/shipment")
    Observable<BaseResponse<List<LogisticsEntity>>> shipment(@Query("orderUuid") String orderUuid);

    /**
     * 退货物流信息
     *
     * @param orderUuid
     * @return
     */
    @GET("frontapi/after-sales/shipment")
    Observable<BaseResponse<List<LogisticsEntity>>> shipmentApply(@Query("orderUuid") String orderUuid);

    @DELETE("frontapi/after-sales/{uuid}")
    Observable<BaseResponse<Object>> deleteSales(@Path("uuid") String uuid);

    @POST("frontapi/after-sales")
    Observable<BaseResponse<Object>> applySales(@Body ApplyAfterSalesEntity req);



    //发放优惠券红包
    @POST("frontapi/user-scores/transfer")
    @FormUrlEncoded
    Observable<BaseResponse<String>> userScores(@Field("amount") String amount,
                                                     @Field("userUuid") String userUuid);
    //发放优惠券红包群聊
    @POST("frontapi/user-scores/transfer-to-group")
    @FormUrlEncoded
    Observable<BaseResponse<String>> userScoresByGroup(@Field("amount") String userCouponUuid,
                                                            @Field("gid") String gid,
                                                            @Field("count") String count);

    //领取优惠券红包
    @POST("frontapi/user-scores/accept")
    @FormUrlEncoded
    Observable<BaseResponse<Object>> userScoresAccept(@Field("transferOrderUuid") String transferOrderUuid);

    @GET("frontapi/coupons/{uuid}")
    Observable<BaseResponse<CardDetailEntity>> getCardDetails(@Path("uuid") String uuid);

    @GET("frontapi/order-product-comments/{uuid}")
    Observable<BaseResponse<CommentsEntity>> getCommentDetail(@Path("uuid") String uuid);

    //点赞产品评价
    @POST("frontapi/order-product-comments/{uuid}/like")
    Observable<BaseResponse<Object>> likeCommentsProduct(@Path("uuid") String uuid);

    @POST("frontapi/order-product-comments/{uuid}/unlike")
    Observable<BaseResponse<Object>> unLikeCommentsProduct(@Path("uuid") String uuid);
    //回复评价
    @POST("frontapi/order-product-comments/sub-comments")
    Observable<BaseResponse<Object>> subComments(@Body SubCommentsReq subCommentsReq);

    //点赞回复
    @POST("frontapi/order-product-comments/sub-comments/{uuid}/like")
    Observable<BaseResponse<Object>> likeSubComments(@Path("uuid") String uuid);

    //取消点赞回复
    @POST("frontapi/order-product-comments/sub-comments/{uuid}/unlike")
    Observable<BaseResponse<Object>> unLikeSubComments(@Path("uuid") String uuid);

    @POST("frontapi/after-sales/shipment")
    Observable<BaseResponse<Object>> shipment(@Body InputLogiReq req);



}
